<template>
  <div>
    <!-- 等待受理 -->
    <apply-acceptance v-if="info.status == 1" :info="info" :username="username" @change-status="changeStatus"/>
    <!-- 受理中 -->
    <apply-accepting v-else-if="info.status == 2" :info="info" :username="username"/>
    <!-- 失败 -->
    <apply-fail v-else-if="info.status == -2" :info="info" :username="username"/>
    <!-- 已发放 -->
    <apply-grant v-else-if="info.status == 10" :info="info" :username="username"/>
    <!-- 已撤回 -->
    <apply-revoke v-else-if="info.status == -1" :info="info" :username="username"/>
  </div>
</template>

<script>
import ApplyAcceptance from './ApplyAcceptance.vue'
import ApplyFail from './ApplyFail.vue'
import ApplyGrant from './ApplyGrant.vue'
import ApplyRevoke from './ApplyRevoke.vue'
import ApplyAccepting from './ApplyAccepting.vue'

export default {
  name: 'ApplyBackDetail',
  components: { 
    ApplyAcceptance,
    ApplyFail,
    ApplyGrant,
    ApplyRevoke,
    ApplyAccepting,
  },
  data() {
    return {
      iid: null,
      info: {},
      username: '',
    }
  },
  created() {
    this.iid = this.$route.params.iid
    this.getRebateInfo(this.iid)
  },
  methods: {
    getRebateInfo(iid) {
      this.axios.get('/apply_id_'+ iid +'.json',{}).then(res => {
        this.info = res.data.info
        this.username = res.data.username
      })
    },
    changeStatus() {
      this.info.status = -1
    }
  },
}
</script>

<style lang="less" scoped>

</style>